package home.actions.main;

import home.actions.base.BaseAction;
import home.db.NoteDAO;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Created by Administrator on 2015/12/10.
 */
public class NewSaveAction extends BaseAction {

    public String execute(HttpServletRequest req, HttpServletResponse resp) throws Exception {
        String title = req.getParameter("title");
        String content = req.getParameter("content");

        if (title == null || "".equals(title.trim())
                || content == null || "".equals(content.trim())) {
            req.getSession().setAttribute("msg", "请输入内容");

            return "toNewPage";
        } else {
            NoteDAO.saveNotes(title, content);

            return "toNewSuccessPage";
        }


    }
}
